from django.db import models

class OpticalDistributionFrame(models.Model):
    location = models.CharField(max_length=255)

    def __str__(self):
        return self.location

class Board(models.Model):
    odf = models.ForeignKey(OpticalDistributionFrame, related_name='boards', on_delete=models.CASCADE)

    def __str__(self):
        return f"{self.odf.location} - Board {self.id}"

class Interface(models.Model):
    board = models.ForeignKey(Board, related_name='interfaces', on_delete=models.CASCADE)
    type = models.CharField(max_length=50)
    status = models.CharField(max_length=50)  # e.g., 'available', 'in_use'
    connected_interface = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL)

    def __str__(self):
        return f"{self.board.odf.location} - Board {self.board.id} - Interface {self.id}"
